package com.gxa.controller;

import com.gxa.common.R;
import com.gxa.service.PurchaseRecordService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Controller
@Api(value = "购货或退货单记录",tags = "购货或退货单记录接口API")
@RequestMapping("/purchaseRecord")
public class PurchaseRecordController {
    R r = new R();
    @Autowired
    PurchaseRecordService purchaseRecordService;

    @RequestMapping(value = "/queryAllRecode",method = RequestMethod.GET)
    @ApiOperation(value = "查询购货或退货单全部记录接口",notes = "查看购货或退货单全部记录", response = R.class)
    @ApiImplicitParam(name = "receipt_purchase_business_type",value = "业务类型",required = true,paramType = "query")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R queryAllRecode(int receipt_purchase_business_type){

        return  purchaseRecordService.queryAllRecode(receipt_purchase_business_type);

    }

    @RequestMapping(value = "/queryOneRecord",method = RequestMethod.GET)
    @ApiOperation(value = "查看购货或退货单单条记录接口",notes = "查看购货或退货单单条记录", response = R.class)
    @ApiImplicitParam(name = "receipt_Purchase_Id",value = "单据编号",required = true,paramType = "query")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R queryOneRecord(String receipt_Purchase_Id){

        return  purchaseRecordService.queryOneRecord(receipt_Purchase_Id);


    }

    @RequestMapping(value = "/queryRecord",method = RequestMethod.GET)
    @ApiOperation(value = "查询购货或退货单记录接口",notes = "查询购货或退货单记录", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "receipt_purchase_business_type",value = "业务类型",required = true,paramType = "query"),
            @ApiImplicitParam(name = "condition", value = "查询条件",  paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始日期",  paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R queryRecord(int receipt_purchase_business_type,String condition, String startDate, String endDate){


        return  purchaseRecordService.queryRecord(receipt_purchase_business_type,condition,startDate,endDate);

    }


    @RequestMapping(value = "/delRecord",method = RequestMethod.POST)
    @ApiOperation(value = "删除购货或退货单记录接口",notes = "删除购货或退货单记录", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R delRecord(@RequestBody@ApiParam(value = "单据编号")Map map){
        System.out.println(map);
        return  purchaseRecordService.delReceiptPurchaseRecord(map);

    }

    @RequestMapping(value = "/reverseAudit",method = RequestMethod.POST)
    @ApiOperation(value = "反审核接口",notes = "反审核", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R reverseAudit(@RequestBody@ApiParam Map map){

        return  purchaseRecordService.reverseAuditReceiptPurchase(map);

    }

}
